#include "CApp.h"
 
CApp::CApp() {
    Surf_Display = nullptr;
    Running = true;
}
 
int CApp::OnExecute() {
    if(OnInit() == false) {
        return -1;
    }

	int testA = 10;

	//assert(testA == 5);
 
    SDL_Event Event;
 
	Uint32 startTick;
	Uint32 startTickLoop;
	Uint32 startTickRender;

    while(Running) {

		//
		if(CSettings::DEBUG_LIFECYCLE)
			startTick = SDL_GetTicks();


        while(SDL_PollEvent(&Event)) {
            OnEvent(&Event);
        }
 
		if(CSettings::DEBUG_LIFECYCLE)
			startTickLoop = SDL_GetTicks();
        OnLoop();
		
		if(CSettings::DEBUG_LIFECYCLE)
		{
			cout<<"OnLoop : "<<SDL_GetTicks()-startTickLoop<<endl;
			startTickLoop = SDL_GetTicks();
		}

		if(CSettings::DEBUG_LIFECYCLE)
			startTickRender = SDL_GetTicks();

		OnRender();

		if(CSettings::DEBUG_LIFECYCLE)
		{
			cout<<"OnRender : "<<SDL_GetTicks()-startTickRender<<endl;
			startTickRender = SDL_GetTicks();
		}


		//
		if(CSettings::DEBUG_LIFECYCLE)
		{
			cout<<"While Cycle : "<<SDL_GetTicks()-startTick<<endl;
			startTick = SDL_GetTicks();
		}
    }
 
    OnCleanup();
 
    return 0;
}
